package com.villaday.idf.adapter2;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.Priority;
import com.bumptech.glide.request.RequestOptions;
import com.villaday.idf.R;
import com.villaday.idf.base.AbsRecyclerViewAdapter;
import com.villaday.idf.base.OnAdapterCallbackListener;
import com.villaday.idf.model.RefreshtokenEntity;
import com.villaday.idf.model2.Home_configurations;
import com.villaday.idf.util.SharedPreferencesUtil;

import byc.imagewatcher.MessagePicturesLayout;

/**
 * 首页动态列表
 */

public class HomeType1Adapter extends AbsRecyclerViewAdapter<Home_configurations.BodyEntity.MiddleAdvertsEntity> {
    private OnAdapterCallbackListener onAdapterCallbackListener;
    private View.OnClickListener onClickListener;
    private MessagePicturesLayout.Callback mCallback;
    private final String roleType;
    private final RequestOptions options;

    public HomeType1Adapter(Context context) {
        super(context, R.layout.item_home2v_type1, /*R.layout.item_dynamic_1, R.layout.item_dynamic_2,*/ R.layout.item_page_loading,
                R.layout.item_page_bottom);
        this.onAdapterCallbackListener = onAdapterCallbackListener;
        this.onClickListener = onClickListener;

        RefreshtokenEntity.BodyBean roleInfo =
                SharedPreferencesUtil.getRoleInfo(context);
        roleType = roleInfo.getMember().getType();

        options = new RequestOptions()
                /*.placeholder(com.m7.imkfsdk.R.drawable.kf_pic_thumb_bg)
                .error(com.m7.imkfsdk.R.drawable.kf_image_download_fail_icon)*/
                .priority(Priority.HIGH);
    }

    @Override
    public int getItemType(Home_configurations.BodyEntity.MiddleAdvertsEntity d) {
        return 0;
    }

    @Override
    public void onBindHolder(AbsRecyclerViewAdapter.RecyclerViewHolder holder, Home_configurations.BodyEntity.MiddleAdvertsEntity d, int position) {


        Glide.with(context).load(d.getMaterial().getUrl())
                .apply(options)
                .into((ImageView) holder.getView(R.id.img));
    }
}
